{extend name="$member_style_layout" /}

{block name="title"}充值{/block}
{block name="content"}
<div class="MainCont">
	<div class="head"><div class="tag">提现</div></div>
    <div class="cont">
        <form name="form1" method="post" action="" class="ajax_post">
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="FormTable">
          <tr>
            <td class="tdL" style="width:180px;">可用余额为:</td>
            <td class="tdR"><span class="b red">{$userdb.rmb}</span>元 {if $getout_percent_money>0}（注意：提现手续费 <span style="color:red;font-weight:bold;">{$getout_percent_money}%</span>）{/if}</td>
          </tr>
          <tr>
            <td class="tdL">提现金额为:(<span class="red">*</span>)</td>
            <td class="tdR"><input type="number" name="money" id="getoutmoney" size="5"> 元 <span id="getrealmoney"></span></td>
          </tr>
{if $webdb.jifen2getoutmoney&&$getout_percent_money>0}
		  <tr>
            <td class="tdL">{$webdb.MoneyName}抵扣手续费:</td>
            <td class="tdR"><input id="payjifenNum" placeholder='你共有{$userdb.money}个' type="number" name="jifen" size="8">个{$webdb.MoneyName}，每个可抵扣 <font style="color:blue;">{:abs($webdb.money_ratio/100)}</font> 元，<span style="display:none;" id="jifenmsg">最多可用 <font style="color:blue;" id="maxjifen">{$userdb.money}</font> 个抵扣 <font id="maxmoney" style="color:blue;">0</font> 元</span></td>
          </tr>
{/if}
          <tr>
            <td class="tdL">支付密码:(<span class="red">*</span>)</td>
            <td class="tdR"><input type="password" name="pwd" size="20"></td>
          </tr>
          <tr>
            <td class="tdL">提现到哪个收款帐户:(<span class="red">*</span>)</td>
            <td class="tdR">
{notempty name="$userdb.weixin_api"}
				<div><input type="radio" name="banktype" value="weixin 微信钱包" checked="true">微信钱包 (强烈推荐,即绑定登录的微信)</div>
{/notempty}

{notempty name="$alipay_id"}
				<div><input type="radio" name="banktype" value="支付宝 {$alipay_id}">支付宝{$alipay_id}</div>
{/notempty}

{volist name="listdb" id="rs"}
              <div><input type="radio" name="banktype" value="{$rs}">{$rs}</div>
{/volist}
            </td>
          </tr>
          <tr>
            <td class="tdL">收款人真实姓名:(<span class="red">*</span>)</td>
            <td class="tdR"><input type="text" name="truename"></td>
          </tr>
          <tr>
            <td class="tdL">联系电话:(选填)</td>
            <td class="tdR"><input type="text" name="tel"></td>
          </tr>
          <tr>
            <td class="tdL">提现备注:(选填)</td>
            <td class="tdR"><textarea name="why" cols="50" rows="5"></textarea></td>
          </tr>

		  <tr>
            <td class="tdL">签名:(<span class="red">*</span>)</td>
            <td class="tdR">
				<div id="signature" style="width:100%;height:200px;border:1px solid red;"></div>
				<input id="clear" type="button" value="清除签名">
			    <input id="save" type="button" value="确认签名">
				<input type="hidden" name="sign_img" id="sign_img">
			</td>
          </tr>

          <tr>
            <td class="tdL"><br/></td>
            <td class="tdR">
            	<input type="submit" name="Submit" value="提交">
                    <input type="hidden" name="step" value="2">
            </td>
          </tr>
        </table>
        </form>
        <ul class="aboutnote">
        	    <div>1.提现最低金额不小于<span style="color:red;font-weight:bold;">{$webdb.min_getout_money|default=50}</span>元,才可提现。{if $getout_percent_money>0}提现会从申请的金额当中扣除 <span style="color:red;font-weight:bold;">{$getout_percent_money}%</span> 作为手续费.{/if}</div>
			  	<div>2.提现金额将会被冻结不可用.推荐选择微信钱包</div>
				<div>3.资料提交后,需人工审核,要1-3天时间处理(遇节假日会延长),请耐心等待.</div>
				{if $webdb.getout_rmb_tn}<div>4.提现T+N周期是 {$webdb.getout_rmb_tn} 天,即最近 {$webdb.getout_rmb_tn} 天内的收入暂不可提现。</div>{/if}
				{if $webdb.getout_need_join_mp}<div>5.提现需要先关注公众号，以方便接收提现动态提醒。</div>{/if}				
				{if ($webdb.getout_need_join_mp && $webdb.mp_code_img)}<div><img src="{$webdb.mp_code_img|tempdir}"></div>{/if}
                    
        </ul>
    </div>
</div>

<script type="text/javascript" src="__STATIC__/libs/jsignature/jSignature.min.noconflict.js"></script>
<script type="text/javascript" charset="utf-8">
			$(document).ready(function() {
				$("#signature").jSignature({height:"100%",width:"100%",color:"#000",lineWidth:5})
			});
			$("#clear").click( function() {
				$("#signature").jSignature("reset");
			});
			$("#save").click( function() {
				var datapair = $("#signature").jSignature("getData", "image");
				var array = datapair.splice(",");
				$.post("{:iurl('index/attachment/upload','dir=images&from=base64&module=marketing')}",{imgBase64:'data:image/png;base64,'+array[1]},res=>{
					if(res.code==1){
						$("#sign_img").val(res.url);
						layer.msg('保存成功');
					}else{
						alert('保存失败');
					}
				});
			});
			/*
			$("#export").click( function() {
				var datapair = $("#signature").jSignature("getData", "image");
				var i = new Image();
				i.src = "data:" + datapair[0] + "," + datapair[1];
				$(i).appendTo($("#pic"));
			});
			*/
</script>


<script type="text/javascript">

$(function(){
	var totaljifen;
	var realJFmoney = 0;
	var realmoney;
	$("#getoutmoney").blur(function(){
		if($(this).val()==''){
			return ;
		}
		if($(this).val()>{$userdb.rmb}){
			layer.alert("提现金额不能大于你的实际可用余额 {$userdb.rmb} 元！");
			return ;
		}else if($(this).val()!='' && $(this).val()<0.01){
			layer.alert("提现金额不能小于0.01元");
			return ;
		}
		realmoney = Number( parseFloat(Number($(this).val())*(100-{$getout_percent_money})/100).toFixed(2) );
		showrealmoney();
		var paymoney = Number( parseFloat(parseFloat($(this).val()) - realmoney).toFixed(2) );
		totaljifen = paymoney*{$webdb.money_ratio};
		if(totaljifen>{$userdb.money}){
			totaljifen = {$userdb.money};
		}
		var jifenmoney = totaljifen/{$webdb.money_ratio};
		$("#maxjifen").html(totaljifen);
		$("#maxmoney").html(jifenmoney);
		$("#jifenmsg").show();
	});

	$("#payjifenNum").blur(function(){
		if($(this).val()==''){
			return ;
		}
		if($("#getoutmoney").val()==''){
			layer.alert("请先输入提现金额！");
			$(this).val('')
			return ;
		}
		var num = Number($(this).val());
		if(num<0){
			layer.alert("不能是负数");
			return ;
		}else if(num>totaljifen){
			layer.alert("不能大于 "+totaljifen+" 个");
			return ;
		}
		realJFmoney = Number( parseFloat(num/{$webdb.money_ratio}).toFixed(2) );
		showrealmoney();
	});

	function showrealmoney(){
		$("#getrealmoney").html("，实际可到帐 <font style='color:red;'>"+realmoney+ (realJFmoney>0?"+"+realJFmoney:'') +"</font> 元");
	}
});
</script>

<!-- 表单常用事件,比如无刷新提交 -->
<script LANGUAGE="JavaScript" src="__STATIC__/js/form/base.js"></script>

{/block}